package Anagram;

import java.io.*;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * User: Vitalii Serdiuk
 * Date: 05.12.13 14:43
 */
public class FileWriter {
    public void writeToFile(String outPathName, Map<String,Set<Word>> wordsTable) {
        PrintWriter out = null;
        try {
            out = new PrintWriter(
                    new BufferedWriter(
                            new java.io.FileWriter(
                                    new File(outPathName))));
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        for (Collection<Word> words : wordsTable.values()) {
            for (Word anagrams : words)
                if (words.size() > 1)
                    out.print(anagrams + " ");

            out.println();
        }

    }
}
